package com.sch.www.ele.services.impl;


import com.sch.www.codeGenerator.base.BaseServicesSimpleImp;
import com.sch.www.ele.entity.Region;
import com.sch.www.ele.entity.RegionExample;
import com.sch.www.ele.mapper.RegionMapper;
import com.sch.www.ele.services.RegionServices;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RegionServicesImpl extends BaseServicesSimpleImp<Region, RegionExample, RegionMapper, RegionServices> implements RegionServices {

    @Override
    protected RegionExample getExampleNewInstance() {
        return new RegionExample();
    }

    @Override
    protected String getTableName() {
        return null;
    }

    @Override
    public List<Region> listByPid(String pid) {
        RegionExample example = new RegionExample();
        example.createCriteria().andPidEqualTo(pid);
        return getMapper().selectByExample(example);
    }

    @Override
    public void insertSelective(String code, String name, String pid) {
        getCurrentProxy().selectById(pid);
        Region region = new Region();
        region.setCode(code);
        region.setName(name);
        region.setPid(pid);
        insertSelective(region);
    }

    @Override
    public void updateByIdSelective(String id, String code, String name) {
        Region region = new Region();
        region.setId(id);
        region.setCode(code);
        region.setName(name);
        updateByIdSelective(region);
    }
}
